function qiurank3D(){
    var _3d=new Object();
}
/**虬髯客3d方法和属性**/
qiurank3D.prototype={

}
/************************二维对象********************************/
qiurank3D.Vector2=function(x,y){
    this.x=x;
    this.y=y;
}
//二维向量对象
qiurank3D.Vector2.prototype={
    normalized: function () {
        return this.div(this.modLen());
    },
    //向量的模，也就是向量AB的长度
    modLen:function(){
        return Math.sqrt(this.x*this.x+this.y*this.y);
    },
    //向量模的平方
    sqrModLen:function(){
        return this.x*this.x+this.y*this.y;
    },
    //拷贝
    copy:function(){
        return  new qiurank3D.Vector2(this.x,this.y);
    },
    //向量的点乘，参数1：二维向量对象
    dot:function(v){
        return this.x* v.x+this.y* v.y;
    },
    //向量相加,参数1：二维向量对象
    plus:function(v){
        return new qiurank3D.Vector2(this.x+ v.x,this.y+ v.y);
    },
    //向量相减,参数1：二维向量对象
    sub:function(v){
        return new qiurank3D.Vector2(this.x- v.x,this.y- v.y);
    },
    //一个数字乘以一个向量,参数1：数字
    mul:function(n){
        return new qiurank3D.Vector2(this.x*n,this.y* n);
    },
    //一个向量除以一个数字,参数1：数字
    div:function(n){
        return new qiurank3D.Vector2(this.x/ n,this.y/n);
    }
}
//由缩放的相同的组件对应乘以这个矢量的每个组件。function Scale (a : Vector2, b : Vector2) : Vector2
qiurank3D.Vector2.Scale=function(v1,v2){
    return new qiurank3D.Vector2(v1.x*v2.x,v1.y*v2.y);
}
//返回v1和v2之间的距离。两个向量之间的距离
qiurank3D.Vector2.Distance=function(v1,v2){
    return qiurank3D.Vector2.Sub(v1,v2).modLen();
}
//返回v1和v2之间的距离的平方。两个向量之间的距离的平方
qiurank3D.Vector2.SqrDistance=function(v1,v2){
    return qiurank3D.Vector2.Sub(v1,v2).sqrModLen();
}
//向量的点乘，参数1：二维向量对象,参数2：二维向量对象
qiurank3D.Vector2.Dot=function(v1,v2){
    return v1.x* v2.x+v1.y* v2.y;
}
//向量相加,参数1：二维向量对象,参数2：二维向量对象
qiurank3D.Vector2.Plus=function(v1,v2){
    return new qiurank3D.Vector2(v1.x+ v2.x,v1.y+ v2.y);
}
//向量相减,参数1：二维向量对象,参数2：二维向量对象
qiurank3D.Vector2.Sub=function(v1,v2){
    return new qiurank3D.Vector2(v1.x- v2.x,v1.y- v2.y);
}
//返回一个由两个向量的最小组件组成的向量。var a : Vector2 = Vector2 (1, 3);var b : Vector2 = Vector2 (4, 2);print (Vector2.Min(a,b)); // prints (1.0,2.0)
qiurank3D.Vector2.Min=function(v1,v2){
    var x=(v1.x>v2.x?v2.x:v1.x);
    var y=(v1.y>v2.y?v2.y:v1.y);
    return new qiurank3D.Vector2(x,y);
}
//返回一个由两个向量的最大组件组成的向量。
/**
 var a : Vector2 = Vector2 (1, 3);
 var b : Vector2 = Vector2 (4, 2);
 print (Vector2.Max(a,b)); // prints (4.0,3.0)
 **/
qiurank3D.Vector2.Max=function(v1,v2){
    var x=(v1.x<v2.x?v2.x:v1.x);
    var y=(v1.y<v2.y?v2.y:v1.y);
    return new qiurank3D.Vector2(x,y);
}
/************************三维对象********************************/

qiurank3D.Vector3=function(x,y,z){
    this.x=x;
    this.y=y;
    this.z=z;
}
//三维向量对象
qiurank3D.Vector3.prototype={
    normalized: function () {
        return this.div(this.modLen());
    },
    //向量的模，也就是向量AB的长度
    modLen:function(){
        return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);
    },
    //向量模的平方
    sqrModLen:function(){
        return this.x*this.x+this.y*this.y+this.z*this.z;
    },
    //拷贝
    copy:function(){
        return   new qiurank3D.Vector3(this.x,this.y,this.z);
    },
    //向量的点乘，参数1：三维向量对象
    dot:function(v){
        return this.x* v.x+this.y* v.y+this.z* v.z;
    },
    //向量相加,参数1：三维向量对象
    plus:function(v){
        return new qiurank3D.Vector3(this.x+ v.x,this.y+ v.y,this.z+ v.z);
    },
    //向量相减,参数1：三维向量对象
    sub:function(v){
        return new qiurank3D.Vector3(this.x- v.x,this.y- v.y,this.z- v.z);
    },
    //一个数字乘以一个向量,参数1：数字
    mul:function(n){
        return new qiurank3D.Vector3(this.x*n,this.y* n,this.z*n);
    },
    //一个向量除以一个数字,参数1：数字
    div:function(n){
        return new qiurank3D.Vector3(this.x/ n,this.y/n,this.z/n);
    },
    //叉乘,两个向量的交叉乘积。返回lhs x rhs,两个向量的叉积与这两个向量的和垂直
    cross : function(v) {
        return new qiurank3D.Vector3(-this.z * v.y + this.y * v.z, this.z * v.x - this.x * v.z, -this.y * v.x + this.x * v.y);
    },
    //取反
    negate : function() {
        return new qiurank3D.Vector3(-this.x, -this.y, -this.z);
    }
}
//由缩放的相同的组件对应乘以这个矢量的每个组件。function Scale (a : Vector3, b : Vector3) : Vector3
qiurank3D.Vector3.Scale=function(v1,v2){
    return new qiurank3D.Vector3(v1.x*v2.x,v1.y*v2.y,v1.z*v2.z);
}
//返回v1和v2之间的距离。两个向量之间的距离
qiurank3D.Vector3.Distance=function(v1,v2){
    return qiurank3D.Vector3.Sub(v1,v2).modLen();
}
//返回v1和v2之间的距离的平方。两个向量之间的距离的平方
qiurank3D.Vector3.SqrDistance=function(v1,v2){
    return qiurank3D.Vector3.Sub(v1,v2).sqrModLen();
}
//向量的点乘，参数1：三维向量对象,参数2：三维向量对象
qiurank3D.Vector3.Dot=function(v1,v2){
    return v1.x* v2.x+v1.y* v2.y+v1.z*v2.z;
}
//向量相加,参数1：三维向量对象,参数2：三维向量对象
qiurank3D.Vector3.Plus=function(v1,v2){
    return new qiurank3D.Vector3(v1.x+ v2.x,v1.y+ v2.y,v1.z+v2.z);
}
//向量相减,参数1：三维向量对象,参数2：三维向量对象
qiurank3D.Vector3.Sub=function(v1,v2){
    return new qiurank3D.Vector3(v1.x- v2.x,v1.y- v2.y,v1.z-v2.z);
}
//返回一个由两个向量的最小组件组成的向量。var a : Vector3 = Vector3 (1, 3);var b : Vector3 = Vector3 (4, 2);print (Vector3.Min(a,b)); // prints (1.0,2.0)
qiurank3D.Vector3.Min=function(v1,v2){
    var x=(v1.x>v2.x?v2.x:v1.x);
    var y=(v1.y>v2.y?v2.y:v1.y);
    var z=(v1.z>v2.z?v2.z:v1.z);
    return new qiurank3D.Vector3(x,y,z);
}
//返回一个由两个向量的最大组件组成的向量。
/**
 var a : Vector3 = Vector3 (1, 3);
 var b : Vector3 = Vector3 (4, 2);
 print (Vector3.Max(a,b)); // prints (4.0,3.0)
 **/
qiurank3D.Vector3.Max=function(v1,v2){
    var x=(v1.x<v2.x?v2.x:v1.x);
    var y=(v1.y<v2.y?v2.y:v1.y);
    var z=(v1.z<v2.z?v2.z:v1.z);
    return new qiurank3D.Vector3(x,y,z);
}
//叉乘,两个向量的交叉乘积。返回lhs x rhs,两个向量的叉积与这两个向量的和垂直
qiurank3D.Vector3.Cross=function(v1,v2) {
    return new qiurank3D.Vector3(-v1.z * v2.y + v1.y * v2.z, v1.z * v2.x - v1.x * v2.z, -v1.y * v2.x + v1.x * v2.y);
}
